import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:qianyi/controller/homeTabController.dart';
import 'package:qianyi/entity/message/Message.dart';
import 'package:qianyi/entity/message/MessageChat.dart';
import 'package:qianyi/entity/mine/User.dart';
import 'package:qianyi/state/token.dart';

import '../../network/http_config.dart';
import '../../network/http_entity.dart';
import '../../network/http_manager.dart';
import '../../ui/widget/custom_refresh_mixin.dart';

class UserViewModel extends ChangeNotifier with CustomRefreshMixin{
  HomeTabController homeTabController = Get.find();
  TextEditingController introduceController = TextEditingController();
  TokenController tokenController = Get.find();
  RefreshController refreshController = RefreshController(initialRefresh: true);
  String avatar = '';
  UserViewModel() {

  }
  User? userEntity;
  @override
  Future<List> requestList(int page) async {
    List tempL = [];
    String uid = tokenController.uid;
    Map<String,dynamic> param = {
      "uid": uid
    };
    HttpEntity httpEntity = await HttpManager.getInstance().request(url: '/platform/user/getUserInfo',method: Method.get,params: param) as HttpEntity;
    User user = User.fromJson(httpEntity.getOriData()['data']);
    this.userEntity = user;
    Map<String,String> params1 = {
      "path": userEntity!.avatar!
    };
    HttpEntity httpEntity1 = await HttpManager.getInstance().request(url: '/util/fileoss/getFileUrl',params: params1,method: Method.get) as HttpEntity;
    this.avatar = httpEntity1.getOriData()['data'];
    tempL.add(user);
    notifyListeners();
    return tempL;
  }






}